//
//  FPCruxTableViewCell.m
//  FilmParadise
//
//  Created by lanou3g on 15/7/13.
//  Copyright (c) 2015年 DLYgroup. All rights reserved.
//

#import "FPCruxTableViewCell.h"

#define imageWidth (kScreenWidth - 30) / 3
#define textColor [UIColor colorWithWhite:0.792 alpha:1.000]

@implementation FPCruxTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self B_TopView];
    }
    return self;
}

// 创建顶部视图
- (void)B_TopView
{
    // 滑动视图
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kImageH((kScreenHeight - 100) / 3))];
    _scrollView.pagingEnabled = YES;
    _scrollView.contentSize = CGSizeMake(kScreenWidth * 7,0);
    _scrollView.bounces = NO;
    _scrollView.showsHorizontalScrollIndicator = NO;// 默认是no
    [self.contentView addSubview:_scrollView];
    
    
    // 循环创建scrollview上的view
    for (int i = 0; i < 7; i ++) {
        self.myView = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth * i, 0, kScreenWidth, kImageH((kScreenHeight - 100) / 3))];
        
        // 日期
        self.dateLabel = [UILabel labelWithFrame:CGRectMake(kImageW(15), 0, kImageW(70), kImageH(20)) text:@"07月17日" fontSize:12.0 fontWeight:1.0 color:[UIColor colorWithWhite:0.792 alpha:1.000]];
        [_myView addSubview:_dateLabel];
        
        // 分割线
        UIView *sepView = [[UIView alloc] initWithFrame:CGRectMake(kImageW(70), kImageH(10), kImageW(kScreenWidth - 70), kImageH(1))];
        sepView.backgroundColor =[UIColor colorWithWhite:0.792 alpha:1.000];
        [_myView addSubview:sepView];
        
        // 影片海报
        self.displayImageView = [UIImageView imageViewWithframe:CGRectMake(kImageW(15), kImageH(20), kImageW((kScreenWidth - 30) / 3), kImageH((kScreenHeight - 100) / 3.5 - 30)) imageName:@"idea-vector" cornerRadius:0 bordeWidth:0 backgroundColor:[UIColor whiteColor]];
        [_myView addSubview:_displayImageView];
        
        // 影片名
        self.filmNameLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 30), kImageH(20), kImageW(200), kImageH(30)) text:@"煎饼侠" fontSize:18.0 fontWeight:2.0 color:[UIColor blackColor]];
        [_myView addSubview:_filmNameLabel];
        
        // 想观看的人数
        self.wantedCountLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 30), kImageH(50), kImageW(50), kImageH(10)) text:@"6666" fontSize:12.0 fontWeight:1.0 color:[UIColor orangeColor]];
        [_myView addSubview:_wantedCountLabel];
        
        // 想看人数标签
        UILabel *peopleLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 60), kImageH(50), kImageW(70), kImageH(10)) text:@"人想看 - " fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:peopleLabel];
        
        // 影片类型
        self.typeLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 110), kImageH(50), kImageW(70), kImageH(10)) text:@"喜剧" fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:_typeLabel];
        
        // 导演和演员标签
        UILabel *label1 = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 30), kImageH(70), kImageW(30), kImageH(10)) text:@"导演:" fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:label1];
        
        UILabel *label2 = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 30), kImageH(90), kImageW(30), kImageH(10)) text:@"演员:" fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:label2];
        
        // 导演
        self.directLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 60), kImageH(70), kImageW(100), kImageH(10)) text:@"董成鹏" fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:_directLabel];
        
        // 演员
        self.actorLabel = [UILabel labelWithFrame:CGRectMake(kImageW(imageWidth + 60), kImageH(90), kImageW(100), kImageH(10)) text:@"董成鹏/袁珊珊" fontSize:12.0 fontWeight:1.0 color:textColor];
        [_myView addSubview:_actorLabel];
        
        // 超前预售/上映提醒
        self.aheadShopButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.aheadShopButton.frame = CGRectMake(kImageW(imageWidth + 30), kImageH(120), kImageW(kScreenWidth / 4), kImageH(30));
        [self.aheadShopButton setTitle:@"超前预售" forState:UIControlStateNormal];
        self.aheadShopButton.backgroundColor = [UIColor colorWithRed:0.000 green:0.688 blue:0.000 alpha:1.000];
        [self.aheadShopButton setTintColor:[UIColor whiteColor]];
        self.aheadShopButton.layer.cornerRadius = kImageH(15);
        self.aheadShopButton.layer.masksToBounds = YES;
        [_myView addSubview:_aheadShopButton];
        
        //预告片
        self.trailerButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.trailerButton.frame = CGRectMake(kImageW(imageWidth + 35 + kScreenWidth / 4), kImageH(120), kImageW(kScreenWidth / 4), kImageH(kImageH(30)));
        [self.trailerButton setTitle:@"预告片" forState:UIControlStateNormal];
        self.trailerButton.backgroundColor = [UIColor colorWithRed:0.000 green:0.688 blue:0.000 alpha:1.000];
        [self.trailerButton setTintColor:[UIColor whiteColor]];
        self.trailerButton.layer.cornerRadius = kImageH(15);
        self.trailerButton.layer.masksToBounds = YES;
        [_myView addSubview:_trailerButton];
        
        _myView.tag = 100 + i;//--------> tag值
        [_scrollView addSubview:_myView];
    }
    UIView * widthView = [[UIView alloc] initWithFrame:CGRectMake(0, kImageH(160), kScreenWidth, kImageH(10))];
    widthView.backgroundColor = textColor;
    [self.contentView addSubview:widthView];
}

/* 本页面所有控件
 UIScrollView *self.contentView;// 滑动视图
 
 UILabel *titleLabel;       // 顶部标题
 UILabel *dateLabel;        // 日期
 UILabel *filmNameLabel;    // 影片名
 UILabel *wantedCountLabel; // 想看人数
 UILabel *typeLabel;        // 影片类型
 UILabel *directLabel;      // 导演
 UILabel *actorLabel;       // 演员
 UIButton *aheadShopButton; // 超前预售/上映提醒
 UIButton *trailerButton;   // 预告片
 UIImageView *displayImageView; // 影片海报
 */

@end
